package com.eqs.enterprisequestionnaire.controller;

import com.eqs.enterprisequestionnaire.result.R;
import com.eqs.enterprisequestionnaire.service.ReliabilityAnalysisService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/reliabilityAnalysis")
public class ReliabilityAnalysisController {
    @Resource
    ReliabilityAnalysisService reliabilityAnalysisService;

    /*
     * 信度分析（获得Cronbach’s Alpha）
     * */
    @GetMapping("/getrealiabilityAnalysis/{questionId}")
    public R<Map<String, List<Double>>> realiabilityAnalysis(@PathVariable Integer questionId) {
        return R.success(reliabilityAnalysisService.getCronbachAnalysis(questionId));
    }


    /*
    * 获得Cronbach’s Alpha
    * */
    @GetMapping("/getCronbach/{questionId}")
    public R<Double> cronbachAnalysis(@PathVariable Integer questionId) {
        Double aDouble = reliabilityAnalysisService.cronbachAnalysis(questionId);
        return R.success(aDouble);
    }
    /*
     * 获得 项已删除的α系数
     * */
    @GetMapping("/getCronbachExceptOption/{optionId}")
    public R<Double> getCronbachExceptOption(@PathVariable Integer optionId) {
        Double aDouble = reliabilityAnalysisService.getCronbachExceptOption(optionId);
        return R.success(aDouble);
    }
    /*
     * 获得 校正的总计相关性(CITC)
     * */
    @GetMapping("/getCITCExceptOption/{optionId}")
    public R<Double> getCITCExceptOption(@PathVariable Integer optionId) {
        Double aDouble = reliabilityAnalysisService.getCITCExceptOption(optionId);
        return R.success(aDouble);
    }
}
